package com.example.demo.collect;

import java.util.List;
import java.util.UUID;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * ClassName: ListSync
 * author: bob.ly
 * Version: 1.0.0
 * DateTime: 2021/07/31-16:02:00
 * Description:
 */
public class ListSync {
    public static void main(String[] args) {
        List<String> list = new CopyOnWriteArrayList<>();
        new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                list.add(UUID.randomUUID().toString());
                System.out.println(list);
            }
        }, "AA").start();
        new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                list.add(UUID.randomUUID().toString());
                System.out.println(list);
            }
        }, "BB").start();
        new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                list.add(UUID.randomUUID().toString());
                System.out.println(list);
            }
        }, "CC").start();
    }
}
